<?php
  /**
   * xPluginsControl
   *
   * The xPluginsControl class 
   *
   * @copyright Copyright (c) 2011, iJBloks Progect
   */
    class PluginsControl extends iJBlock{
        
        /**
         *
         * Class Constructuctor
         * @access public
         */
        public function __construct() {
    
        }
        
        
        /**
         * execute
         *
         * Executes the block to generate the tokens
         *
         * @return array Array with the tokens of the block
         *
         * @access public
         */
        public function execute() {
          $iJPlugins     = iJFactory::singleton('iJPlugins');
          $iJLanguages   = iJFactory::singleton('iJLanguages');
          
          $page   = isset($_REQUEST['page'])                                  ? $_REQUEST['page']   : 1;
          $search = isset($_REQUEST['search']) && !empty($_REQUEST['search']) ? $_REQUEST['search'] : '';


          $pluginsList = $iJPlugins->getPluginsList($page, $search);
          $plugins       = $pluginsList[0];
          $QPlugin      = $pluginsList[1];
          
          
          $this->addToken('plugins',            $plugins);         
          $this->addToken('search',             $search);
          $this->addToken('page',               $page);
          $this->addToken('icon',               iJHrefLink::Icon('plugin_go', '16x16'));
          $this->addToken('delete_icon',        iJHrefLink::Icon('trash', '16x16'));
          $this->addToken('edit_icon',          iJHrefLink::Icon('edit', '16x16'));
          $this->addToken('form_action',        iJHrefLink::linkToLocalPage('admin_plugins'));           
          $this->addToken('curLanguage',        $iJLanguages->getLanguage());
          $this->addToken('languages',          $iJLanguages->getLanguagesExeptCurrent());  
          
          $this->addToken('total_items',    $QPlugin->getSize());
          $this->addToken('pages_count',    $QPlugin->getPagesCount());
          $this->addToken('prev_link',      $QPlugin->getPerviousLink($page, 'admin_blocks'));
          $this->addToken('next_link',      $QPlugin->getNextLink($page, 'admin_blocks'));

          return parent::execute();
        }
        
    }
?>